<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <title>MSRS Intro to Autonomous Robotics Tutorial</title>
    <link href="Styles/Standard.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div class="page">
<a href="http://sky.fit.qut.edu.au/~taylort2/MSRS/index.htm"><img src="Images/MSRSCodePage.jpg" alt="MSRS Code Page Home" border="0" /></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<img src="Images/IntroBanner.gif" alt="MSRS Intro Program" />
<hr />
<p class="heading"><span class="dropcap">T</span>utorial for Intro to Autonomous Robotics</p>
<p>This is a very basic tutorial that introduces you to the Microsoft
Robotics Studio and some simple robotics concepts. No hardware is required,
i.e. you do not need a robot. The Simulator will provide a simulated
robot for you to work with.</p>
<p>
Once you have tried out this Intro program, you should look at the Microsoft
Robotics Tutorials.
</p>
<p><b>NOTE:</b> This program requires the <a href="../MazeSimulator/MazeSimulator.htm">Maze Simulator</a> which is included in the download.</p>

<h2>Background</h2>
<p>
The Microsoft Robotics Studio provides an environment for building robotics applications.
This Intro program uses the MSRS Framework to control a simulated robot in a
maze-like world.
</p>
<p>
<b>NOTE:</b> You can select either the Pioneer 3DX robot (which is the default) or
the Lego NXT robot in the Maze Simulator. You do NOT specify the robot type in
the Intro program because it just uses the Maze Simulator.
</p>
<p>
In robotics, there is no clear definition of an autonomous robot. One meaning is that
the robot is free to move around and is not restricted by a tether or "umbilical"
cable for controlling the robot or feeding it power. Another meaning is that the
robot as enough on-board intelligence to operate without human intervention.
</p>
<p>
This Intro program can be considered to be running inside the robot. Of course,
we know that is not true. So if it makes more sense to you, assume that the program
is sending commands to the robot over a wireless network, and the robot is also
sending back data to the program. In that case, the program is running on your PC
which is effectively the "brain" that controls the robot.
</p>
<h3>Sensors</h3>
<p>
The information coming from the robot is called Sensor data.
</p>
<p>
There are two types
of sensor data: <b>proprioceptive</b> and <b>exteroceptive</b>. These big words just mean
internal and external. Internal information could include things like the battery
voltage so that the robot knows when it is running out of power and needs to
recharge. External information is about the world around the robot, like the
distance to the nearest obstacle, the ambient temperature or even images
from a video camera.
</p>
<p>
In this introductory example, we use the simplest of all sensors -- a bumper.
A bumper is just a switch that senses when the robot runs into some other
object.</p>
<p>Bumpers are called a <b>contact sensors</b> because the robot actually makes contact,
i.e. bumps into, the obstacle. If this obstacle happens to be a human, then it
could be harmful to the human! If it is a wall, then it might damage the robot.
Either way, this is not a good sensor. Therefore bumpers are usually used as
a last resort in case the other sensors have failed.</p>
<p>
The Pioneer robot in the simulation has two bumpers, one at the front
and another at the back. The Lego NXT only has one bumper at the front.
</p>
<p>
The simulated Pioneer robot actually has a Laser Range Finder (LRF) as well which is
a <b>range sensor</b>, i.e. it measures the distance to obstacles. However, this is
not used in this simple program. The advantage of a LRF is that it does not require
the robot to go around crashing into things! However, a real LRF is very expensive.
</p>
<p>
Although it is not used by the Intro program, the simulated Pioneer robot has a camera
mounted on top of it. You can see the view from this camera by pressing F8 in the
simulation window or selecting it from the Camera menu. The Lego NXT does not have
a camera.
</p>
<h3>Actuators</h3>
<p>
Actuators do things. (They are usually called <b>effectors</b> for robotic arms.)
In our case, the only actuators that we can control on the robot are its wheels.
</p>
<p>
The Pioneer and Lego NXT robots both have two wheels and the motor speed can be
controlled independently for each wheel. (In case you are wondering how a robot
balances, there is a third non-driven wheel called a jockey or castor wheel.
The castor wheel can spin around to roll
in any direction just like the wheels on an office chair.)
</p>
<p>
This configuration with two wheels on a common axis is called a <b>Differential Drive</b>
because the two wheels can rotate in different directions.
By appropriately adjusting the power to the two motors, the robot can move forwards,
backwards, rotate on the spot, or move in an arc.
</p>
<h2>Running the Intro</h2>
<p>
The <a href="IntroDocumentation.htm">Documentation</a> page has instructions for running the program.
</p>
<p>
When Intro starts, it will create two windows: A <a href="Images/SimulatorInitialView.jpg">Simulator</a>
and a <a href="Images/Dashboard.gif">Dashboard</a>. These are
shown below. Click on the images for larger views.
</p>
<a href="Images/SimulatorInitialView.jpg"><img src="Images/SimulatorInitialView_small.jpg" alt="Simulator View" hspace="5" border="0" /></a><a href="Images/Dashboard.gif"><img src="Images/Dashboard_small.gif" alt="Dashboard" hspace="5" border="0" /></a>
<p>
Once you have it running, and the Dashboard is connected, you need to
deliberately drive the robot into a wall to trigger the wandering
<b>behaviour</b>. Running into a wall generates bumper messages, which
the program is listening for.</p>
<p>
Debugging information is displayed in
the MSRS DOS window to let you know what the program is doing. You
should see messages indicating that the robot has bumped into
something, and that the program is setting the wheel speeds.
</p>
<p>
<b>NOTE:</b> The robot has inertia, just like a real robot, and it also takes
some time for the motors to reach the desired speed. This means that
there will be some lag between when you move the trackball on the
Dashboard and when the robot responds. Play around and get a feel for it.
</p>

<h3>Behaviours</h3>
<p>
In robotics, a behaviour is a high-level function that we might
consider as "intelligence". Backing away from a wall when you
bump into one seems a pretty intelligent thing to do!
</p>
<p>
To simplify the problem, we try to divide up the task of programming a robot
into a number of layers. At the bottom level are the actuators and sensors
and the associated low-level software. The Microsoft Robotics Studio defines
this layer in such a way that it independent of the type of robot.
</p>
<p>
At a higher level, we have behaviours. (There might be some intermediate
levels as well, depending on the framework.) A single behaviour might work on
many different robots, provided that the lower layers hide the details
of how the robot actually works.
</p>
<p>
The behaviour in the Intro program is fairly complex.
It works as follows:
</p>
<ul>
<li>
The robot bumps into a wall.
</li>
<li>
The program stops the robot immediately so that it can settle down.
</li>
<li>
Then the robot backs up a little way.</li>
<li>
Next it turns left or right for a little while (selected at random).
</li>
<li>
Finally, the program chooses a new speed setting (randomly)
and the robot drives off in search of another wall.
</li>
</ul>
<p>
Because the motor speeds vary randomly for each step,
the robot will effectively wander around. Sometimes however, it will
spend a lot of time bumping up against the wall, or will immediately
run into the wall again after taking off. It is not a very smart
program!
</p>
<p>
<b>NOTE:</b> There are several parameters in the configuration file
that control this behaviour. You can experiment by editing the file
and changing them. A copy of the file is included in the ZIP and is
called Intro.Config.xml. This file must be located in the MSRS "store"
directory. However, the first time that you run the program it will
create the config file if it does not exist.
</p>
<p>
Watch the robot for a while. Notice that it seems to spend a lot of time
bumping into the walls. This can't be good for the robot, but luckily it
is just a sim.
</p>
<p>
It is also possible that the robot might knock itself over. This is
particularly true for the Lego NXT, although the Pioneer is powerful
enough to knock itself over too. Once this happens you will have to
restart the program because there is no way to pick up the robot and
set it on its wheels again.
</p>
<p>
If you leave the program to run for long enough, eventually the robot
should visit most of the maze world. This might take a very long time,
but it is the same principle that pool cleaners use to clean the bottom
of a swimming pool. Some vacuum cleaning robots also wander around
randomly, but usually they are smart enough not to bump into things because
they have infra-red sensors.
</p>
<h2>What have you learnt?</h2>
<p>
This Intro covered several topics:
</p>
<ul>
<li>You have started using the Microsoft Robotics Studio.</li>
<li>You now know what a bump sensor is, and why it is not a good sensor to use!</li>
<li>You've seen a robot executing an autonomous behaviour.</li>
<li>You know one simple way to explore the world, although it is not very efficient.</li>
</ul>
<p>
This program still needs a lot of work, which is the challenge of robotics!
Just when you think you have the perfect program, the robot will do something
strange. Thinking with a literal mind like a robot is not easy for us humans.
Basically, we know too much and we can apply our common sense!
</p>
<p>
Sometimes these strange behaviours appear to be really smart, but
you don't remember writing any code for them! These are called "emergent
behaviours" because they emerge from a set of other behaviours to create
a "super" behaviour. Unfortunately, not all emergent behaviours are useful.
</p>
<h2>Where to from here?</h2>
<p>
This page is a very simple tutorial! It is intended to get you up and running
quickly and hopefully inspire you to start hacking away at your own
robotics code.
</p>
<p>
You should open the Intro program in Visual Studio and look through it.
I have put a lot of comments in the code. The DssNewService program
generated the basic structure, and I have included references to the
Microsoft Tutorials to show where some of the additional code came from.
</p>
<p>
Now that you have run a program, I suggest doing the Microsoft Tutorials.
Note that you can use the Maze Simulator with Robotics Tutorial 1,
so you don't need a real robot. 
</p>
<p>
When you create the manifest for Robotics Tutorial 1, ignore the instruction
that tells you to put in a Lego NXT bumper. In other words, do NOT add:
</p>
<tt>
&lt;!-- Start the NXT Bumper with default port 1 --&gt;<br />
&lt;ServiceRecordType&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&lt;dssp:Contract&gt;http://schemas.microsoft.com/2006/06/legonxtbumper.html&lt;/dssp:Contract&gt;<br />
&lt;/ServiceRecordType&gt;<br />
</tt>
<p>
Instead, put in the Maze Simulator and Dashboard from the manifest for
the Intro Program. Due to the magic of MSRS, the simulated bumper will be
used instead of the real Lego bumper. Here is the replacement code:
</p>
<p>
<tt>
&lt;ServiceRecordType&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&lt;dssp:Contract&gt;http://schemas.tempuri.org/2006/08/mazesimulator.html&lt;/dssp:Contract&gt;<br />
&lt;/ServiceRecordType&gt;<br />

&lt;ServiceRecordType&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&lt;dssp:Contract&gt;http://schemas.microsoft.com/robotics/2006/10/dashboard.html&lt;/dssp:Contract&gt;<br />
&lt;/ServiceRecordType&gt;<br />
</tt>
</p>
<p>
Or, if you want to use the Simple Dashboard then use the following service record
instead of the one above for the Dashboard. (Note carefully that the dates are
different as well as the filenames.)<br />
<tt>
&lt;ServiceRecordType&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&lt;dssp:Contract&gt;http://schemas.microsoft.com/robotics/2006/01/simpledashboard.html&lt;/dssp:Contract&gt;<br />
&lt;/ServiceRecordType&gt;<br />
</tt>
</p>
<p>
Tutorial 2 is hard to do with a simulator because you have to push the
bumper to make a motor work. You can probably do it using the Simulator
camera to nudge the robot. You might just want to read this tutorial.
</p>
<p>
Robotics Tutorial 3 is based on the
Fisher Technik robot. The Intro program does the same
thing with a simulated Pioneer 3DX, but better. In fact,
the Intro is based on Tutorial 3. So read through Tutorial 3
while you are looking at the code for the Intro program. See
if you can pick out the differences.
</p>
<p>
That's all there is to it. Have fun playing with your simulated robot!
</p>

<p>
<a href="Intro.htm">[&nbsp;Overview&nbsp;]</a>&nbsp;|&nbsp;<a href="IntroDocumentation.htm">[&nbsp;Documentation&nbsp;]</a>
</p>

<hr />
<div class="footer">
Page maintained by:
<a href="m&#97;&#105;&#108;t&#111;:T.Taylor&#64;qut&#46;edu&#46;au">T.Taylor&#64;qut.edu.au</a>
&nbsp;&nbsp;&nbsp;Last Updated: 18-Jul-2007
</div>

</div>

</body>
</html>
